import requests
import execjs
class jsk():
    def __init__(self):
        self.cookies = {
            'Hm_lvt_03b8714a30a2e110b8a13db120eb6774': '1745512552',
            'HMACCOUNT': '16A20218A710F4B0',
            'DJO_BASIC_P': 'YTYzMTI2MDgtNDJlMS00YWE4LWIwNjktZTc1Y2YyOTZjNjUw',
            'Hm_lpvt_03b8714a30a2e110b8a13db120eb6774': '1745512570',
        }

        self.headers = {
    'accept': 'application/json, text/plain, */*',
    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    'content-type': 'application/json;charset=UTF-8',
    'devicetype': 'PC',
    'origin': 'https://www.jiansheku.com',
    'page': 'search-enterprise',
    'priority': 'u=1, i',
    'referer': 'https://www.jiansheku.com/',
    'sec-ch-ua': '"Microsoft Edge";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-site',
    'sign': 'f10a30fcfc0ab147a4bbbe6b11a82fdc',
    'timestamp': '1745513345529',
    'token': 'd38b030a84c9488285bbe44f28c46e21',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0',
    # 'cookie': 'Hm_lvt_03b8714a30a2e110b8a13db120eb6774=1745512552; HMACCOUNT=16A20218A710F4B0; DJO_BASIC_P=YTYzMTI2MDgtNDJlMS00YWE4LWIwNjktZTc1Y2YyOTZjNjUw; Hm_lpvt_03b8714a30a2e110b8a13db120eb6774=1745512570',
}

        self.request_url = 'https://capi.jiansheku.com/nationzj/enterprice/page'

       
        self.cookies = {
            'Hm_lvt_03b8714a30a2e110b8a13db120eb6774': '1745512552',
            'HMACCOUNT': '16A20218A710F4B0',
            'DJO_BASIC_P': 'YTYzMTI2MDgtNDJlMS00YWE4LWIwNjktZTc1Y2YyOTZjNjUw',
        }

        self.json_data = {"eid":"","achievementQueryType":"and","achievementQueryDto":[],"personnelQueryDto":{"queryType":"and"},"aptitudeQueryDto":{"queryType":"and","nameStr":"","ename":"中国建筑","aptitudeQueryType":"and","businessScopeQueryType":"or","filePlaceType":"1","aptitudeDtoList":[{"codeStr":"","queryType":"and","aptitudeType":"qualification"}],"aptitudeSource":"new","outCodeStr":"","outQueryType":"or"},"page":{"page":2,"limit":20,"field":"","order":""}}

        self.js = execjs.compile(open('建设库.js', encoding='utf-8').read()).call('get_sign',self.json_data)

        print(self.js)

    def get_data(self):
        self.headers['sign'] = str(self.js[1])
        self.headers['timestamp'] = str(self.js[0])
        print(self.headers)
        response = requests.post(self.request_url, cookies=self.cookies, headers=self.headers, json=self.json_data)
        print(response.json())
if __name__ == '__main__':
           
   
    jsk=jsk()
    jsk.get_data()
